package java_thinking.unit_19._19_1_6;

import java.util.Random;

/**
 * @Desc:   修改EnumImplementation 编写一个static next()方法取代实现Generater 接口，对比两种方式有什么优缺点
 * @author: cww
 * @DateTime: 2019/5/22 20:04
 */
enum CartoonCharacter1 {
    SLAPPY, SPANKY, PUNCHY, SILLY, BOUNCY, NUTTY, BOB;
    private static Random rand = new Random(47);
    public static CartoonCharacter1 next() {
        return values()[rand.nextInt(values().length)];
    }
}
public class E02_EnumStaticImplementation {
    public static void printNext() {
        System.out.print(CartoonCharacter1.next() + ", ");
    }

    /**
     * static next()后调用next()就无需使用CartoonCharacter了
     * @param args
     */
    public static void main(String[] args) {
        for(int i = 0; i < 10; i++)
            printNext();
    }
}
